package system.model.converter;

import com.google.common.collect.Lists;
import common.model.po.SysAuthority;
import system.model.vo.AuthorityTreeNodeVo;

import java.util.List;

/**
 * 功能描述
 *
 * @author 米泽鹏
 * @since 2021-9-3 下午 11:06
 */
public class SysAuthorityConverter {

	public static List<AuthorityTreeNodeVo> poListToAuthorityTreeNodeVoList(List<SysAuthority> authorityList) {
		List<AuthorityTreeNodeVo> menuTreeNodeList = Lists.newArrayList();
		if (authorityList != null && !authorityList.isEmpty()) {
			authorityList.forEach(temp -> {
				AuthorityTreeNodeVo menuTreeNode = poToAuthorityTreeNodeVo(temp);
				menuTreeNodeList.add(menuTreeNode);
			});
		}
		return menuTreeNodeList;
	}

	public static AuthorityTreeNodeVo poToAuthorityTreeNodeVo(SysAuthority sysAuthority) {
		if (sysAuthority == null) {
			return null;
		}
		AuthorityTreeNodeVo authorityTreeNodeVo = new AuthorityTreeNodeVo();
		authorityTreeNodeVo.setParentId(sysAuthority.getParentId());
		authorityTreeNodeVo.setSort(sysAuthority.getSort());
		authorityTreeNodeVo.setType(sysAuthority.getType());
		authorityTreeNodeVo.setName(sysAuthority.getName());
		authorityTreeNodeVo.setTitle(sysAuthority.getTitle());
		authorityTreeNodeVo.setPath(sysAuthority.getPath());
		authorityTreeNodeVo.setUrl(sysAuthority.getUrl());
		authorityTreeNodeVo.setComponent(sysAuthority.getComponent());
		authorityTreeNodeVo.setRedirect(sysAuthority.getRedirect());
		authorityTreeNodeVo.setResources(sysAuthority.getResources());
		authorityTreeNodeVo.setHidden(sysAuthority.getHidden());
		authorityTreeNodeVo.setIcon(sysAuthority.getIcon());
		authorityTreeNodeVo.setKeepAlive(sysAuthority.getKeepAlive());
		authorityTreeNodeVo.setAffix(sysAuthority.getAffix());
		authorityTreeNodeVo.setAlwaysShow(sysAuthority.getAlwaysShow());
		authorityTreeNodeVo.setDescription(sysAuthority.getDescription());
		authorityTreeNodeVo.setId(sysAuthority.getId());
		authorityTreeNodeVo.setOperator(sysAuthority.getOperator());
		authorityTreeNodeVo.setCreateTime(sysAuthority.getCreateTime());
		authorityTreeNodeVo.setUpdateTime(sysAuthority.getUpdateTime());
		return authorityTreeNodeVo;
	}

}
